import { RoutesAlias } from '../routesAlias'
import { AppRouteRecord } from '@/types/router'

/**
 * 菜单列表、异步路由
 *
 * 支持两种模式:
 * 前端静态配置 - 直接使用本文件中定义的路由配置
 * 后端动态配置 - 后端返回菜单数据，前端解析生成路由
 *
 * 菜单标题（title）:
 * 可以是 i18n 的 key，也可以是字符串，比如：'用户列表'
 *
 * RoutesAlias.Layout 指向的是布局组件，后端返回的菜单数据中，component 字段需要指向 /index/index
 * 路由元数据（meta）：异步路由在 asyncRoutes 中配置，静态路由在 staticRoutes 中配置
 */
export const asyncRoutes: AppRouteRecord[] = [
  {
    name: 'Dashboard',
    path: '/dashboard',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.dashboard.title',
      icon: '&#xe721;',
      roles: ['R_SUPER', 'R_ADMIN']
    },
    children: [
      {
        path: 'console',
        name: 'Console',
        component: RoutesAlias.Dashboard,
        meta: {
          title: 'menus.dashboard.console',
          keepAlive: false,
          fixedTab: true
        }
      }
    ]
  },
  {
    path: '/orders',
    name: 'Orders',
    component: RoutesAlias.Orders,
    meta: {
      title: '订单列表',
      icon: '&#xe721;',
      roles: ['R_SUPER']
    }
  },
  {
    path: '/accommodation',
    name: 'Accommodation',
    component: RoutesAlias.Accommodation,
    meta: {
      title: '住宿管理',
      icon: '&#xe721;',
      roles: ['R_SUPER']
    }
  },
  {
    path: '/activity',
    name: 'Activity',
    component: RoutesAlias.Layout,
    meta: {
      title: '活动管理',
      icon: '&#xe721;',
      roles: ['R_SUPER']
    },
    children: [
      {
        path: 'groupBuy',
        name: 'GroupBuy',
        component: RoutesAlias.GroupBuy,
        meta: {
          title: '团购活动'
        }
      },
      {
        path: 'buyItNow',
        name: 'BuyItNow',
        component: RoutesAlias.BuyItNow,
        meta: {
          title: '一口价'
        }
      }
    ]
  },
  {
    path: '/system',
    name: 'System',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.system.title',
      icon: '&#xe7b9;',
      roles: ['R_SUPER', 'R_ADMIN']
    },
    children: [
      {
        path: 'user',
        name: 'User',
        component: RoutesAlias.User,
        meta: {
          title: 'menus.system.user',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'role',
        name: 'Role',
        component: RoutesAlias.Role,
        meta: {
          title: 'menus.system.role',
          keepAlive: true,
          roles: ['R_SUPER']
        }
      },
      {
        path: 'user-center',
        name: 'UserCenter',
        component: RoutesAlias.UserCenter,
        meta: {
          title: 'menus.system.userCenter',
          isHide: true,
          keepAlive: true,
          isHideTab: true
        }
      },
      {
        path: 'menu',
        name: 'Menus',
        component: RoutesAlias.Menu,
        meta: {
          title: 'menus.system.menu',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            }
          ]
        }
      }
    ]
  }
  // {
  //   path: '/result',
  //   name: 'Result',
  //   component: RoutesAlias.Layout,
  //   meta: {
  //     title: 'menus.result.title',
  //     icon: '&#xe715;'
  //   },
  //   children: [
  //     {
  //       path: 'success',
  //       name: 'ResultSuccess',
  //       component: RoutesAlias.Success,
  //       meta: {
  //         title: 'menus.result.success',
  //         keepAlive: true
  //       }
  //     },
  //     {
  //       path: 'fail',
  //       name: 'ResultFail',
  //       component: RoutesAlias.Fail,
  //       meta: {
  //         title: 'menus.result.fail',
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/exception',
  //   name: 'Exception',
  //   component: RoutesAlias.Layout,
  //   meta: {
  //     title: 'menus.exception.title',
  //     icon: '&#xe820;'
  //   },
  //   children: [
  //     {
  //       path: '403',
  //       name: '403',
  //       component: RoutesAlias.Exception403,
  //       meta: {
  //         title: 'menus.exception.forbidden',
  //         keepAlive: true
  //       }
  //     },
  //     {
  //       path: '404',
  //       name: '404',
  //       component: RoutesAlias.Exception404,
  //       meta: {
  //         title: 'menus.exception.notFound',
  //         keepAlive: true
  //       }
  //     },
  //     {
  //       path: '500',
  //       name: '500',
  //       component: RoutesAlias.Exception500,
  //       meta: {
  //         title: 'menus.exception.serverError',
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // }
]
